2 module
.exports = function ( grunt
) {
3 grunt
.loadNpmTasks( 'grunt-contrib-copy' );
4 grunt
.loadNpmTasks( 'grunt-contrib-jshint' );
5 grunt
.loadNpmTasks( 'grunt-contrib-watch' );
6 grunt
.loadNpmTasks( 'grunt-banana-checker' );
7 grunt
.loadNpmTasks( 'grunt-jscs' );
8 grunt
.loadNpmTasks( 'grunt-jsonlint' );
9 grunt
.loadNpmTasks( 'grunt-karma' );
11 var wgServer
= process
.env
.MW_SERVER
,
12 wgScriptPath
= process
.env
.MW_SCRIPT_PATH
,
15 karmaProxy
[wgScriptPath
] = wgServer
+ wgScriptPath
;
24 '{includes,languages,resources,tests}/**/*.js'
30 // Auto-generated file with JSON (double quotes)
31 '!tests/qunit/data/mediawiki.jqueryMsg.data.js',
32 // Skip functions are stored as script files but wrapped in a function when
33 // executed. node-jscs trips on the would-be "Illegal return statement".
34 '!resources/src/*-skip.js'
36 // Exclude all files ignored by jshint
37 ].concat( grunt
.file
.read( '.jshintignore' ).split( '\n' ).reduce( function ( patterns
, pattern
) {
38 // Filter out empty lines
39 if ( pattern
.length
&& pattern
[0] !== '#' ) {
40 patterns
.push( '!' + pattern
);
48 '{languages,maintenance,resources}/**/*.json',
53 core
: 'languages/i18n/',
54 api
: 'includes/api/i18n/',
55 installer
: 'includes/installer/i18n/'
60 '<%= jsonlint.all %>',
70 pattern
: wgServer
+ wgScriptPath
+ '/index.php?title=Special:JavaScriptTest/qunit/export',
75 frameworks
: [ 'qunit' ],
76 reporters
: [ 'dots' ],
79 // Some tests in extensions don't yield for more than the default 10s (T89075)
80 browserNoActivityTimeout
: 60 * 1000
83 browsers
: [ 'Chrome' ]
86 browsers
: [ 'Chrome', 'Firefox' ]
91 src
: 'resources/**/*',
92 dest
: 'docs/js/modules',
94 rename: function ( dest
, src
) {
95 return require( 'path' ).join( dest
, src
.replace( 'resources/', '' ) );
101 grunt
.registerTask( 'assert-mw-env', function () {
102 if ( !process
.env
.MW_SERVER
) {
103 grunt
.log
.error( 'Environment variable MW_SERVER must be set.\n' +
104 'Set this like $wgServer, e.g. "http://localhost"'
107 if ( !process
.env
.MW_SCRIPT_PATH
) {
108 grunt
.log
.error( 'Environment variable MW_SCRIPT_PATH must be set.\n' +
109 'Set this like $wgScriptPath, e.g. "/w"');
111 return !!( process
.env
.MW_SERVER
&& process
.env
.MW_SCRIPT_PATH
);
114 grunt
.registerTask( 'lint', ['jshint', 'jscs', 'jsonlint', 'banana'] );
115 grunt
.registerTask( 'qunit', [ 'assert-mw-env', 'karma:main' ] );
117 grunt
.registerTask( 'test', ['lint'] );
118 grunt
.registerTask( 'default', 'test' );